asm
  ld sp,$CFFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $C010
dim seed as uinteger at $C012
dim ee0 as uinteger at $C014
dim ee1 as uinteger at $C016
dim ee2 as uinteger at $C018
dim ee3 as uinteger at $C01A
dim ee4 as uinteger at $C01C
dim eex as uinteger at $C020
dim eey as uinteger at $C022

seed=0

sub solomonskeyputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte, tly1 as uinteger):
  poke $D000+$800*tly1+typ1*32+txp1,tat1
  poke $D400+$800*tly1+typ1*32+txp1,tch1
  end sub

sub solomonskeypalette(tid1 as uinteger,tvl1 as uinteger):
  poke uinteger $E400+tid1*2,tvl1
  end sub

sub solomonskeypalettergb(tid1 as uinteger,tvl1 as uinteger):
  poke uinteger $E400+tid1*2,((tvl1 band $0F0) bor ((tvl1 band $F00)/256) ) bor ((tvl1 band $F)*256)
  end sub

sub solomonskeyputsprite(tly1 as uinteger,txp1 as ubyte,typ1 as ubyte,tch1 as ubyte,tat1 as ubyte):
  poke uinteger $E000+tly1*4,txp1
  poke uinteger $E001+tly1*4,typ1
  poke uinteger $E002+tly1*4,tch1
  poke uinteger $E003+tly1*4,tat1
  end sub



for ee0=0 to 255
  seed=smsrnd(seed)
  solomonskeypalettergb(ee0,seed)
  next

solomonskeypalettergb(0,$F00)
solomonskeypalettergb(1,$0F0)
solomonskeypalettergb(2,$00F)
solomonskeypalettergb(3,$700)
solomonskeypalettergb(4,$070)
solomonskeypalettergb(5,$007)

solomonskeypalettergb(128,$444)

solomonskeypalettergb($0,$444)
solomonskeypalettergb($5,$666)
solomonskeypalettergb($A,$888)
solomonskeypalettergb($F,$AAA)


for ee0=0 to 31
  for ee1=0 to 31
    seed=smsrnd(seed):ee2=seed
    seed=smsrnd(seed)
    solomonskeyputchar(ee1,ee0,seed band $F,ee2 band %11110000,0)
    next:next

for ee0=0 to 16
  for ee1=0 to 16
    solomonskeyputchar(ee1+14,ee0+13,ee0*16+ee1,0,0)
    next:next


eex=8:eey=8
eee=0
do

solomonskeyputchar(1,3,48+(int(eee/100) mod 10),0,0)
solomonskeyputchar(2,3,48+(int(eee/10) mod 10),0,0)
solomonskeyputchar(3,3,48+(eee mod 10),0,0)

ee0=peek($E600)
solomonskeyputchar(1,5,48+(int(ee0/100) mod 10),0,0)
solomonskeyputchar(2,5,48+(int(ee0/10) mod 10),0,0)
solomonskeyputchar(3,5,48+(ee0 mod 10),0,0)
eex=eex+((ee0 band 1)/1)-((ee0 band 2)/2)
eey=eey-((ee0 band 4)/4)+((ee0 band 8)/8)

ee0=peek($E601)
solomonskeyputchar(1,6,48+(int(ee0/100) mod 10),0,0)
solomonskeyputchar(2,6,48+(int(ee0/10) mod 10),0,0)
solomonskeyputchar(3,6,48+(ee0 mod 10),0,0)

ee0=peek($E602)
solomonskeyputchar(1,7,48+(int(ee0/100) mod 10),0,0)
solomonskeyputchar(2,7,48+(int(ee0/10) mod 10),0,0)
solomonskeyputchar(3,7,48+(ee0 mod 10),0,0)

ee0=peek($E603)
solomonskeyputchar(1,8,48+(int(ee0/100) mod 10),0,0)
solomonskeyputchar(2,8,48+(int(ee0/10) mod 10),0,0)
solomonskeyputchar(3,8,48+(ee0 mod 10),0,0)

ee0=peek($E604)
solomonskeyputchar(1,9,48+(int(ee0/100) mod 10),0,0)
solomonskeyputchar(2,9,48+(int(ee0/10) mod 10),0,0)
solomonskeyputchar(3,9,48+(ee0 mod 10),0,0)

ee0=peek($E605)
solomonskeyputchar(1,10,48+(int(ee0/100) mod 10),0,0)
solomonskeyputchar(2,10,48+(int(ee0/10) mod 10),0,0)
solomonskeyputchar(3,10,48+(ee0 mod 10),0,0)



solomonskeyputchar(eex,eey,eee,0,0)


eee=eee+1
smsdelay(10000)
loop


do:loop

'-----------------------------------------------------------------


do

for eee=$D000 to $D3FF 'colorram1
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

for eee=$D400 to $D7FF 'videoram1
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

for eee=$D800 to $DBFF 'colorram2
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

for eee=$DC00 to $DFFF 'videoram2
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

for eee=$E000 to $E07F 'spriteram
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

for eee=$E400 to $E5FF 'palette
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

loop

do:loop




'-----------------------------------------------------
'$BFFF
'-----------------------------------------------------
goto flg02:
asm
  org $F000
  end asm
flg02:
'-----------------------------------------------------
'$F000
'-----------------------------------------------------




''static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, solomon_state )
''	AM_RANGE(0x0000, 0xbfff) AM_ROM
''	AM_RANGE(0xc000, 0xcfff) AM_RAM
''	AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(solomon_colorram_w) AM_SHARE("colorram")
''	AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(solomon_videoram_w) AM_SHARE("videoram")
''	AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(solomon_colorram2_w) AM_SHARE("colorram2")
''	AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(solomon_videoram2_w) AM_SHARE("videoram2")
''	AM_RANGE(0xe000, 0xe07f) AM_RAM AM_SHARE("spriteram")
''	AM_RANGE(0xe400, 0xe5ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
''	AM_RANGE(0xe600, 0xe600) AM_READ_PORT("P1")
''	AM_RANGE(0xe601, 0xe601) AM_READ_PORT("P2")
''	AM_RANGE(0xe602, 0xe602) AM_READ_PORT("SYSTEM")
''	AM_RANGE(0xe603, 0xe603) AM_READ(solomon_0xe603_r)
''	AM_RANGE(0xe604, 0xe604) AM_READ_PORT("DSW1")
''	AM_RANGE(0xe605, 0xe605) AM_READ_PORT("DSW2")
''	AM_RANGE(0xe606, 0xe606) AM_READNOP /* watchdog? */
''	AM_RANGE(0xe600, 0xe600) AM_WRITE(nmi_mask_w)
''	AM_RANGE(0xe604, 0xe604) AM_WRITE(solomon_flipscreen_w)
''	AM_RANGE(0xe800, 0xe800) AM_WRITE(solomon_sh_command_w)
''	AM_RANGE(0xf000, 0xffff) AM_ROM
''ADDRESS_MAP_END
'
'
'
'
'
'sub tecmoresetwatchdog()
'  poke $F80B,255
'  end sub
'
'for eee=$E800 to $EFFF '- paletteram
'  seed=smsrnd(seed)
'  poke eee,seed
'  tecmoresetwatchdog()
'  next
'
'for eee=$D000 to $D7FF '- txvideoram
'  poke eee,code(" ")
'  tecmoresetwatchdog()
'  next
'
'for eee=0 to 15
'  for ee2=0 to 15
'    poke $D000+((eee+12)*32)+((ee2+14)*1),(eee*16)+ee2
'    poke $D400+((eee+12)*32)+((ee2+14)*1),2
'    tecmoresetwatchdog()
'    next:next
'
''for eee=$E000 to $E7FF '- spriteram
''  for ee2=1 to 100:next
''  seed=smsrnd(seed)
''  poke eee,seed
''  tecmoresetwatchdog()
''  next
'
'ex0=128:ey0=128
'eee=0
'seed=0
'do
'  ej0=peek($F800)
'  'poke uinteger $E800,$C804 '- #C84
'
'  'for eee=$D800 to $DBFF '- fgvideoram
'  '  for ee2=1 to 100:next
'  '  seed=smsrnd(seed)
'  '  poke eee,seed
'  '  tecmoresetwatchdog()
'  '  next
'
'  'for eee=$DC00 to $DFFF '- bgvideoram
'  '  for ee2=1 to 100:next
'  '  seed=smsrnd(seed)
'  '  poke eee,seed
'  '  tecmoresetwatchdog()
'  '  next
'
'  tecmoresetwatchdog()
'
'  'poke $F800,int(eee/32)
'  'poke $F803,int(eee/64)
'  'poke $F802,int(eee/128)
'  'poke $F805,int(eee/256)
'
'  poke $F800,int(ex0/2)
'  poke $F802,int(ey0/2)
'  poke $F803,int(ex0/4)
'  poke $F805,int(ey0/4)
'
'
'  poke ($D000+(24*32)+8),48+(eee mod 10)
'  poke ($D000+(24*32)+7),48+((int(eee/10)) mod 10)
'  poke ($D000+(24*32)+6),48+((int(eee/100)) mod 10)
'  poke ($D000+(24*32)+5),48+((int(eee/1000)) mod 10)
'  poke ($D000+(24*32)+4),48+((int(eee/10000)) mod 10)
'
'  poke ($D000+(25*32)+8),48+(ej0 mod 10)
'  poke ($D000+(25*32)+7),48+((int(ej0/10)) mod 10)
'  poke ($D000+(25*32)+6),48+((int(ej0/100)) mod 10)
'
'  if (ej0 band 1)<> 0 then:ex0=ex0-1:end if
'  if (ej0 band 2)<> 0 then:ex0=ex0+1:end if
'  if (ej0 band 4)<> 0 then:ey0=ey0+1:end if
'  if (ej0 band 8)<> 0 then:ey0=ey0-1:end if
'
'
'  eee=eee+1
'  loop
'
''-------------------------------------------------------------------------------
''dim ee2 as uinteger at $4C06
''dim ee3 as uinteger at $4C08
''dim ee4 as ubyte at $4C0A
''dim ecsp as ubyte at $4C0C
''dim ecsq as ubyte at $4C0E
''
''dim ex1 as uinteger at $4C14
''dim ey1 as uinteger at $4C16
''dim ex2 as uinteger at $4C18
''dim ey2 as uinteger at $4C1A
''dim ex3 as uinteger at $4C1C
''dim ey3 as uinteger at $4C1E
''
''dim ex4 as uinteger at $4C20
''dim ey4 as uinteger at $4C22
''dim ex5 as uinteger at $4C24
''dim ey5 as uinteger at $4C26
''dim ex6 as uinteger at $4C28
''dim ey6 as uinteger at $4C2A
''dim ex7 as uinteger at $4C2C
''dim ey7 as uinteger at $4C2E
''
'
''
''function test1(t1 as uinteger,t2 as uinteger,t3 as uinteger,t4 as uinteger)  as uinteger
''  end function
''
''sub zpoke(t1 as uinteger,t2 as ubyte)
''  poke t1,t2
''  end sub
''
''sub putchar(tx1 as uinteger, ty1 as uinteger, tch1 as uinteger)
''  poke ($4000+(tx1*32)+ty1) bxor %0000001111100000,(tch1 band 255)
''  end sub
''
''pacmanputsprite(0,21,10,4,3)
''pacmanputsprite(1,21,30,4,3)
''pacmanputsprite(2,21,50,4,3)
''pacmanputsprite(3,21,70,4,3)
''pacmanputsprite(4,21,90,4,3)
''pacmanputsprite(5,21,110,4,3)
''pacmanputsprite(6,21,130,4,3)
''pacmanputsprite(7,21,150,4,3)
''
''seed=0
''
''poke $4300,code("*")
''poke $4200,code("*")
''poke $4100,code("*")
''
''poke $4010,code("0")
''poke $400F,code("1")
''poke $4030,code("2")
''poke $402F,code("3")
''
''poke $43D0,code("0")
''poke $43CF,code("1")
''poke $43F0,code("2")
''poke $43EF,code("3")
''
''for ee2=0 to 11
''  poke ($4000+((ee2+12)*32)+13) bxor %0000001111100000,peek(@text01+ee2)
''  next
''
''for ee2=0 to 11
''  poke ($4000+(0*32)+(ee2+12)) bxor %0000000000011111,peek(@text01+ee2)+64
''  next
''
''for ee2=0 to 11
''  poke ($4000+(31*32)+(ee2+12)) bxor %0000000000011111,peek(@text01+ee2)+128
''  next
''
''ee4=0
''for ee3=15 to 15+15
''  for ee2=12 to 12+15
''    poke ($4000+(ee2*32)+ee3) bxor %0000001111100000,ee4
''    ee4=ee4+1
''    next
''    next
''
''for ee2=22 to 25
''  for ee3=6 to 9
''    poke ($4000+(ee2*32)+ee3) bxor %0000001111100000,code("X")
''    next
''    next
''
''test1(377,2445,63888,2342)
''
''eee=$4207
''i=code("Q")
''poke eee,i
''eee=eee+1
''i=code("T")
''poke eee,i
''
''seed=0
''for eee=$4400 to $47FF
''  seed=smsrnd(seed)
''  poke eee,seed
''  next
''
''ex0=20:ey0=10
''ex1=20:ey1=30
''ex2=20:ey2=50
''ex3=20:ey3=70
''ex4=20:ey4=90
''ex5=20:ey5=110
''ex6=20:ey6=130
''ex7=20:ey7=150
''eee=0
''ecsp=0:ecsq=0
''
''do
''poke $50C0,255 '- watchdog? - it seems to work! thanks, Jim Bagley!!!!
''
''ej0=peek($5000) bxor $ff
''ej1=peek($5040) bxor $ff
''
''poke ($4000+(6*32)+20) bxor %0000001111100000,ej0
''poke ($4000+(7*32)+20) bxor %0000001111100000,ej1
''
''poke ($4000+(8*32)+22) bxor %0000001111100000,48+(ex0 mod 10)
''poke ($4000+(7*32)+22) bxor %0000001111100000,48+((int(ex0/10)) mod 10)
''poke ($4000+(6*32)+22) bxor %0000001111100000,48+((int(ex0/100)) mod 10)
''
''poke ($4000+(8*32)+23) bxor %0000001111100000,48+(ey0 mod 10)
''poke ($4000+(7*32)+23) bxor %0000001111100000,48+((int(ey0/10)) mod 10)
''poke ($4000+(6*32)+23) bxor %0000001111100000,48+((int(ey0/100)) mod 10)
''
''poke ($4000+(8*32)+24) bxor %0000001111100000,48+(eee mod 10)
''poke ($4000+(7*32)+24) bxor %0000001111100000,48+((int(eee/10)) mod 10)
''poke ($4000+(6*32)+24) bxor %0000001111100000,48+((int(eee/100)) mod 10)
''poke ($4000+(5*32)+24) bxor %0000001111100000,48+((int(eee/1000)) mod 10)
''poke ($4000+(4*32)+24) bxor %0000001111100000,48+((int(eee/10000)) mod 10)
''
''poke ($4000+(8*32)+25) bxor %0000001111100000,48+(ej0 mod 10)
''poke ($4000+(7*32)+25) bxor %0000001111100000,48+((int(ej0/10)) mod 10)
''poke ($4000+(6*32)+25) bxor %0000001111100000,48+((int(ej0/100)) mod 10)
''
''poke ($4000+(8*32)+26) bxor %0000001111100000,48+(ej1 mod 10)
''poke ($4000+(7*32)+26) bxor %0000001111100000,48+((int(ej1/10)) mod 10)
''poke ($4000+(6*32)+26) bxor %0000001111100000,48+((int(ej1/100)) mod 10)
''
''poke ($4000+(8*32)+27) bxor %0000001111100000,48+(ecsp mod 10)
''
''
''if ecsp=0 then:
''  if (ej0 band 1)<>0 then: ey0=ey0-1:end if
''  if (ej0 band 2)<>0 then: ex0=ex0-1:end if
''  if (ej0 band 4)<>0 then: ex0=ex0+1:end if
''  if (ej0 band 8)<>0 then: ey0=ey0+1:end if
''  end if
''
''if ecsp=1 then:
''  if (ej0 band 1)<>0 then: ey1=ey1-1:end if
''  if (ej0 band 2)<>0 then: ex1=ex1-1:end if
''  if (ej0 band 4)<>0 then: ex1=ex1+1:end if
''  if (ej0 band 8)<>0 then: ey1=ey1+1:end if
''  end if
''
''if ecsp=2 then:
''  if (ej0 band 1)<>0 then: ey2=ey2-1:end if
''  if (ej0 band 2)<>0 then: ex2=ex2-1:end if
''  if (ej0 band 4)<>0 then: ex2=ex2+1:end if
''  if (ej0 band 8)<>0 then: ey2=ey2+1:end if
''  end if
''
''if ecsp=3 then:
''  if (ej0 band 1)<>0 then: ey3=ey3-1:end if
''  if (ej0 band 2)<>0 then: ex3=ex3-1:end if
''  if (ej0 band 4)<>0 then: ex3=ex3+1:end if
''  if (ej0 band 8)<>0 then: ey3=ey3+1:end if
''  end if
''
''if ecsp=4 then:
''  if (ej0 band 1)<>0 then: ey4=ey4-1:end if
''  if (ej0 band 2)<>0 then: ex4=ex4-1:end if
''  if (ej0 band 4)<>0 then: ex4=ex4+1:end if
''  if (ej0 band 8)<>0 then: ey4=ey4+1:end if
''  end if
''
''if ecsp=5 then:
''  if (ej0 band 1)<>0 then: ey5=ey5-1:end if
''  if (ej0 band 2)<>0 then: ex5=ex5-1:end if
''  if (ej0 band 4)<>0 then: ex5=ex5+1:end if
''  if (ej0 band 8)<>0 then: ey5=ey5+1:end if
''  end if
''
''if ecsp=6 then:
''  if (ej0 band 1)<>0 then: ey6=ey6-1:end if
''  if (ej0 band 2)<>0 then: ex6=ex6-1:end if
''  if (ej0 band 4)<>0 then: ex6=ex6+1:end if
''  if (ej0 band 8)<>0 then: ey6=ey6+1:end if
''  end if
''
''if ecsp=7 then:
''  if (ej0 band 1)<>0 then: ey7=ey7-1:end if
''  if (ej0 band 2)<>0 then: ex7=ex7-1:end if
''  if (ej0 band 4)<>0 then: ex7=ex7+1:end if
''  if (ej0 band 8)<>0 then: ey7=ey7+1:end if
''  end if
''
''if (ej1 band 15)<>0 then: ecsq=ecsq+1:end if
''ecsp=(int(ecsq/4))mod 8
''
''ee3=int(eee/4)
''
''pacmanputsprite(0,ex0,ey0,4,3)  '- layer,x,y,id,clut
''pacmanputsprite(1,ex1,ey1,ee3,3)  '- layer,x,y,id,clut
''pacmanputsprite(2,ex2,ey2,4,ee3)  '- layer,x,y,id,clut
''pacmanputsprite(3,ex3,ey3,ee3,ee3)  '- layer,x,y,id,clut
''pacmanputsprite(4,ex4,ey4,4,3)  '- layer,x,y,id,clut
''pacmanputsprite(5,ex5,ey5,ee3,3)  '- layer,x,y,id,clut
''pacmanputsprite(6,ex6,ey6,4,ee3)  '- layer,x,y,id,clut
''pacmanputsprite(7,ex7,ey7,ee3,ee3)  '- layer,x,y,id,clut
''
''eee=eee+1
''loop
''
'''-------------------------------------------------------------------------------
''
''do
''loop
''
'''-------------------------------------------------------------------------------
''
''text01:
''asm
''  defb "HELLO WORLD!!!!!"
''  end asm
''
'''-------------------------------------------------------------------------------
''
''poke $5000,255
''
'''- this should put some characters on the pattern display area
''for i=0 to 255
''  poke $4040+i,i
''  poke $4440+i,i
''  next
''
''do
''loop
''
'''-------------------------------------------------------------------------------
''
''
''
